﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProductList.ascx.cs" Inherits="admin_ProductList" %>
<%@ Register Src="~/Controls/DisplayRating.ascx" TagName="RatingDisplay" TagPrefix="efish" %>
<%@ Register Src="~/Controls/AvailabilityDisplay.ascx" TagName="AvailabilityDisplay" TagPrefix="efish" %>
<%@ Import Namespace="efish.Framework.Web"%>

<asp:GridView ID="gvwProducts" runat="server"  AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="ID" PageSize="10"
    AllowSorting="True" EmptyDataText="<b>There is no product to show for the selected department</b>" OnRowCreated="gvwProducts_RowCreated">
   <Columns>
      <asp:ImageField DataImageUrlField="SmallImageUrl" ItemStyle-Width="110px" />     
      <asp:HyperLinkField HeaderText="Product" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
         DataTextField="Title" DataNavigateUrlFormatString="~/Store/ShowProduct.aspx?ID={0}" DataNavigateUrlFields="ID" />
      <asp:TemplateField HeaderText="Rating">
         <ItemTemplate>
            <div style="text-align: center">            
            <efish:RatingDisplay runat="server" ID="ratDisplay" Value='<%# Eval("AverageRating") %>' Visible='<%# (int)Eval("Votes") > 0 %>' />
            </div>
         </ItemTemplate>         
      </asp:TemplateField>
      <asp:TemplateField HeaderText="Available" SortExpression="UnitsInStock" ItemStyle-HorizontalAlign="Center">
         <ItemTemplate>
            <div style="text-align: center">
               <efish:AvailabilityDisplay runat="server" ID="availDisplay" Value='<%# Eval("UnitsInStock") %>' />
            </div>
         </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="Price" SortExpression="UnitPrice" HeaderStyle-HorizontalAlign="Right">
         <ItemTemplate>
            <div style="text-align: right">
               <asp:Panel ID="Panel1" runat="server" Visible='<%# (int)Eval("DiscountPercentage") > 0 %>'>
                  <s><%# (this.Page as BasePage).FormatPrice(Eval("UnitPrice")) %></s><br />
                  <b><%# Eval("DiscountPercentage") %>% Off</b><br />
               </asp:Panel>
               <%# (this.Page as BasePage).FormatPrice(Eval("FinalUnitPrice")) %>
            </div>
         </ItemTemplate>         
      </asp:TemplateField>
      <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20px">
         <ItemTemplate>
            <asp:HyperLink runat="server" ID="lnkEdit" ToolTip="Edit product"
               NavigateUrl='<%# "~/Admin/AddEditProduct.aspx?ID=" + Eval("ID") %>' ImageUrl="~/images/Edit.gif" />
         </ItemTemplate>         
      </asp:TemplateField>
      <asp:CommandField ButtonType="Image" DeleteImageUrl="~/images/Delete.gif" DeleteText="Delete product" ShowDeleteButton="True">
         <ItemStyle HorizontalAlign="Center" Width="20px" />
      </asp:CommandField>
   </Columns>   
   <EmptyDataTemplate><b>No products to show</b></EmptyDataTemplate>   
</asp:GridView>